<?php
/*
 * Criado em 24/11/2009
 * Autor: Neykson
 * E-mail: neykson@gmail.com
 */

class Conexao {
	
	public  $con;
	function __construct() {
	
	}
	
	public function abreConexao()
	{
		
		$OS = explode(" ",php_uname()); 
		if($OS[0] == "Windows")
		{
			$file    = "D:\\Sistema\\conexao.xml"; // Windows
		}else{
			$file    = "/home/sophistic1/conexao.xml"; // Linux
		}
		$xml = simplexml_load_file($file);
		try 	
		{	
			//$con = new PDO($this->tipo.":host=".$this->host.";dbname=".$this->banco,$this->usuario,$this->senha);
			$con = new PDO($xml->db_driver.":host=".$xml->host.";dbname=".$xml->dbname,$xml->db_user,$xml->db_password);
			$con->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); //PDO::ATTR_ERRMODE,PDO::MYSQL_ATTR_USE_BUFFERED_QUERY 
			return $con;
		}catch(PDOException $e){
			return die($e->getMessage());
		}
	}
	
	public function fechaConexao()
	{
		$con = NULL;
	}
}

?>